<?php
/**
Exibe um formul�rio para a altera��o de uma reserva j� cadastrado no banco de dados.
*/

if(!isset($_SESSION))
{
   session_start();
}

if( !function_exists('__autoload') )
{
    function __autoload($class_name) {
    require_once $class_name . '.php';
    }
}

SAEO::ValidarAcesso( array( 0, 2 ) );


$ano = new Ano();
$anosCadastrados = $ano->CarregarAnos() # carrega do banco de dados todos os anos cadastrados e retorna o resultado em um array
?>
<html>
           <head>
           <title>SAEO - Buscar Rateio</title>
           <script type='text/javascript' src='templates/programa.js'></script>
           <script type='text/javascript' src='templates/campus.js'></script>
           <script type='text/javascript' src='templates/setor.js'></script>
           <script type='text/javascript' src='templates/reserva.js'></script>
           <script type='text/javascript' src='templates/fonte.js'></script>
           <script type='text/javascript' src='templates/hintbox.js'></script>
           <script type='text/javascript' src='templates/js.js'></script>
           <script type='text/javascript' src='templates/ajax.js'></script>
           <script type='text/javascript' src='templates/validacoes.js'></script>
           <link rel='stylesheet' type='text/css' href='templates/estilos.css'/>           

           </head>
     <body class='body' onload='CarregarProgramas( document.buscar_rateio.anoId.value );'>
     <form name='buscar_rateio' id='buscar_rateio' action='ListarRateio.php' method='get' onsubmit=''>
     <table width='779' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#FFFFFF'>
            <input type="hidden" name="operacao" value="<?php echo $_GET['operacao'];?>" />
            <tr>
                <td colspan='2'><?php include "Topo.php"; ?></td>
            </tr>
            <tr>
                <td colspan='2'><div class='titulosTabelas' style='width:779; height:20; background:url(templates/tabela.jpg)'>BUSCA DE RATEIOS</div></td>
            </tr>
            <tr>
                <td colspan='2'>&nbsp;</td>
            </tr>
            <tr>
                <td colspan='2'><table class='tabela' width='650' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#FFFFFF'>
                           <tr>
                               <td colspan='2'>&nbsp;</td>
                           </tr>
<!--                            <tr>
                               <td class='textoTabelas' width='30%'>&nbsp;Pesquisar Por:</td>
                               <td class='textoTabelas'>
                                   <select name='anoId' id='anoId' class='inputTexto'  onchange='ProcessarOpcoesDeBusca( this.value );' >
                                           <option value='0'>Selecione o filtro</option>
                                           <option value='processo'>Processo</option>
                                           <option value='campus'>Unidade</option>
                                           <option value='periodo'>Periodo</option>
                                           <option value='setor'>Setor</option>
                                   </select>                                   
                               </td> 
                           </tr>-->
						<tr>
							<td class='textoTabelas'>&nbsp;Ano:</td>
							<td>
								<select name='anoId' id="anoId" class='inputTexto' style="width: 99px;" onchange='CarregarProgramas( this.value );'>                             
                               			<?php
                               			$anoAtual = $ano->getAnoAtual(); 
			                            // Percorre o array anosCadastrados e cria options para cada posi��o.
			                            for ($i = 0; $i < count( $anosCadastrados ); $i++){
			                            	$status = $anoAtual == $anosCadastrados[$i]->ano ? "selected" : "";
			                            	echo "<option value='".$anosCadastrados[$i]->id."' $status>".$anosCadastrados[$i]->ano."</option>";
			                            }
										?>
                               </select> 
								<a href='#' class='hintanchor' onMouseover='showhint("Ano do Programa cadastrado no sistema.", this, event, "220px");'>[?]</a>
							</td>
						</tr>
						<tr>
							<td>&nbsp;</td>
						</tr>
						<tr>
							<td width="35%" class='textoTabelas'>&nbsp;A&ccedil;&atilde;o Or&ccedil;ament&aacute;ria:</td>
							<td>
								<select name="programaId" id="listaProgramas" class='inputTexto' style="width: 310px;" onchange="FiltrarFontes(this.value);">                             
                               			<option value="0" id="programa">Selecione Primeiro o Ano...</option>
                               </select> 
								<a href='#' class='hintanchor' onMouseover='showhint("Lista de Programas cadastrados no sistema.", this, event, "220px");'>[?]</a>
							</td>						
						<tr>
							<td colspan='2'>&nbsp;</td>
						</tr>
						<tr>
							<td class='textoTabelas'>&nbsp;Tipo de despesa:</td>
							<td>
								<select name='tipoDespesa' id="tipoDespesa" class='inputTexto' style="width: 310px;" onchange="MostrarDiv ( this.value, getElementById('informacaoRateio'));">
										<option value="0" id="despesa">Selecione o Tipo de Despesa</option>                             
										<option value="T" id="despesa">Todos</option>
                               			<option value="33" id="despesa">33 - Corrente</option>
                               			<option value="44" id="despesa">44 - Capital</option>
                               </select> 
								<a href='#' class='hintanchor' onMouseover='showhint("Tipo de Despesa da Fonte.", this, event, "220px");'>[?]</a>
							</td>
						</tr>
                           <tr>
                               <td colspan='2'>&nbsp;</td>
                           </tr>
						<tr>
							<td class='textoTabelas'>&nbsp;Fonte de Recurso:</td>
							<td>
								<select name='fonteId' id="listaFontes" class='inputTexto' style="width: 310px;" >                             
                               			<option value="0" id="fonte">Selecione Primeiro o Tipo de Despesa...</option>
                               </select> 
								<a href='#' class='hintanchor' onMouseover='showhint("C&oacute;digo da Fonte de Recurso.", this, event, "220px");'>[?]</a>
							</td>
						</tr>                           
                           <tr>
                               <td colspan='2'>&nbsp;</td>
                           </tr>                           
                            <tr>
                               <td colspan='2'>
                                   <div id='informacaoRateio' style='display:none;'>
                                                                     
                                    <table class='tabela' width='650' style='border-style: none' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#FFFFFF'>
                                    	<tbody id="tbCampoFonte">
                                        </tbody>                                        
                                          <tr>
                                              <td colspan='2'>&nbsp;</td>
                                          </tr>
                                          <tr>
                                              <td colspan='2' height='46'><input type='image' style='width:100px;height:30px;position:relative;left:540px' src='templates/btavancar.JPG'/></td>
                                          </tr>
                                   </table>
                               </div>
                               </td>
                           </tr>
                     </table>
                </td>
            </tr>
            <tr>
                <td colspan='2'>&nbsp;</td>
            </tr>
            <tfoot>
                   <tr>
                   		<td><?php include 'rodapeCreditos.php'; ?></td>
                   </tr>
            </tfoot>
     </table>
     </form>
     </body>
     </html>
